package com.rongxun.main.model;

import android.app.Application;

import com.rongxun.api.UserInfoManager;
import com.rongxun.api.dao.response.Advertisement;
import com.rongxun.api.dao.response.UIConfiguration;
import com.rongxun.common.base.mvvm.model.BaseModel;

import io.reactivex.Flowable;
import io.reactivex.functions.Function;

/**
 * 创建者     forza
 * 创建时间   2019/11/29 18:09
 * 描述
 */
public class SplashModel extends BaseModel {

    public SplashModel(Application application) {
        super(application);
    }


    public Flowable<Advertisement> getUIConfiguration() {

        return getApiManager().getUIConfiguration().map(new Function<UIConfiguration, Advertisement>() {
            @Override
            public Advertisement apply(UIConfiguration uiConfiguration) {

                if (uiConfiguration.getAppSwitch().equals(UserInfoManager.NO_TRANSACTION)) {

                    UserInfoManager.getInstance(mApplication).setUIConfig(UserInfoManager.NO_TRANSACTION);

                } else {

                    UserInfoManager.getInstance(mApplication).setUIConfig(UserInfoManager.NEED_TRANSACTION);

                }


                return uiConfiguration.getAdvertising();
            }
        });

    }
}